package view;

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import controller.ACSystem;
import model.Auction;
import model.NonProfit;

import java.awt.Color;
import java.awt.Dimension;
import java.util.ArrayList;

import javax.swing.border.LineBorder;

/**
 * The nonProfit Pane class 
 * @author Bob Landowski
 */
@SuppressWarnings("serial")
public class NonProfitPane extends JPanel {

	/** The np Auction History */
	private JTable NPAuctionHistory_table;
	
	/** The non profit */
	private NonProfit my_nonProfit;
	
	/** The Organization */
	private String my_organization;
	
	/** The first name */
	private String my_first_name;
	
	/** The last name */
	private String my_last_name;
	
	/** The address 1 */
	private String my_address1;
	
	/** The address 2 */
	@SuppressWarnings("unused")
	private String my_address2;
	
	/** The apartment number */
	@SuppressWarnings("unused")
	private String my_apt_num;
	
	/** The city */
	private String my_city;
	
	/** The state */
	private String my_state;
	
	/** The zip */
	private String my_zip;
	
	/** The phone */
	private String my_phone;
	
	/** The email */
	private String my_email;
	
	/** The list of Auctions */
	@SuppressWarnings("unused")
	private ArrayList<Auction> my_auctions;
	
	/** The Organization field */
	private JLabel organizationField;
	
	/** The contact name field */
	private JLabel contactNameField;
	
	/** The email field */
	private JLabel email;
	
	/** The phone field */
	private JLabel phone;
	
	/** The address field */
	private JLabel address;
	
	/** The address2 field */
	private JLabel address2;
	
	/** The ACcontroller */
	@SuppressWarnings("unused")
	private ACSystem my_ACcontroller;

	/**
	 * Create the panel.
	 * @author Bob Landowski
	 * @author Eric Struck
	 */
	public NonProfitPane(final ACSystem the_ACcontroller) {
		setBorder(new LineBorder(new Color(0, 0, 0), 5));
		my_ACcontroller = the_ACcontroller;
		setLayout(null);
		setPreferredSize(new Dimension(500,500));

		contactNameField = new JLabel("my_contact_name");
		contactNameField.setBackground(Color.BLACK);
		contactNameField.setForeground(Color.BLACK);
		contactNameField.setBounds(130, 82, 130, 20);
		add(contactNameField);

		JLabel name_label = new JLabel("Contact Name:");
		name_label.setBounds(16, 82, 80, 20);
		add(name_label);

		JLabel address_label = new JLabel("Address:");
		address_label.setBounds(16, 112, 69, 20);
		add(address_label);

		JLabel phone_label = new JLabel("Phone:");
		phone_label.setBounds(16, 172, 69, 20);
		add(phone_label);

		address = new JLabel(my_address1);
		address.setBounds(130, 112, 295, 20);
		add(address);

		address2 = new JLabel(my_city + ", " + my_state + " " + my_zip);
		address2.setBounds(130, 142, 338, 20);
		add(address2);

		phone = new JLabel(my_phone);
		phone.setBounds(130, 172, 69, 20);
		add(phone);

		JLabel email_label = new JLabel("Email:");
		email_label.setBounds(16, 202, 69, 20);
		add(email_label);

		email = new JLabel(my_email);
		email.setBounds(130, 202, 197, 20);
		add(email);

		JLabel AuctionCentralNonProfit = new JLabel("Auction Central Non-Profit Screen");
		AuctionCentralNonProfit.setBounds(92, 16, 287, 20);
		add(AuctionCentralNonProfit);

		JScrollPane bid_history_scroll_pane = new JScrollPane();
		bid_history_scroll_pane.setBounds(60, 256, 330, 88);
		add(bid_history_scroll_pane);

		NPAuctionHistory_table = new JTable();
		NPAuctionHistory_table.setModel(new DefaultTableModel(new Object[][] {
				{ 1 }, { 2 }, { 3 }, { 4 }, { 5 }, { 6 }, { 7 }, { 8 }, { 9 },
				{ 10 }, }, new String[] { "Auction History" }));
		bid_history_scroll_pane.setViewportView(NPAuctionHistory_table);
		
		JLabel organizationNameLabel = new JLabel("Organization:");
		organizationNameLabel.setBounds(16, 52, 80, 20);
		add(organizationNameLabel);
		
		organizationField = new JLabel("my_organization");
		organizationField.setBounds(130, 52, 130, 20);
		add(organizationField);

	}

	/** 
	 * The  getObjectData method 
	 */
	public void getObjectData(Object the_object){
		my_nonProfit = (NonProfit)the_object;

		my_organization = my_nonProfit.getMy_organization();
		organizationField.setText(my_organization);
		my_first_name = my_nonProfit.get_first_name();
		my_last_name = my_nonProfit.get_last_name();
		contactNameField.setText(my_first_name + " " + my_last_name);
		my_address1 = my_nonProfit.getMy_address().getMy_address1();
		address.setText(my_address1);
		my_address2 = my_nonProfit.getMy_address().getMy_address2();
		my_apt_num = my_nonProfit.getMy_address().getMy_apt_num();
		my_city = my_nonProfit.getMy_address().getMy_city();
		my_state = my_nonProfit.getMy_address().getMy_state();
		my_zip = my_nonProfit.getMy_address().getMy_zip();
		address2.setText(my_city + ", " + my_state + " " + my_zip);
		my_phone = my_nonProfit.getMy_phone();
		phone.setText(my_phone);
		my_email = my_nonProfit.getMy_email();
		email.setText(my_email);
		my_auctions = my_nonProfit.listPreviousAuctions();
	}
}
